
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cglist.css"/>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/add.css"/>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cg_info.css"/>
    <script type="text/javascript" src="/plan/caigou/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/caigou/js/layer.js" ></script>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/layer.css"/>

    <script type="text/javascript" src="/plan/caigou/js/rem.js" ></script>
    <title>出货单详情</title>
</head>
<style>
    #add1{display: block}
    #add3{display: none}
    .cglist li p.cginfo{
        height: .38rem;
        padding-top: .2rem;
    }
</style>
<section id="add1">
    <div>
        <ul class="cglist">
            <li>

                <p class="number">
                    <span class="num_left">{$info['khmc']}</span>
                    {$info['status_text']}
                </p>
                <p class="cginfo">
                    <span>单据编号</span>{$info['order_id']}
                </p>
                <p class="cginfo">
                    <span>联系手机</span>{$info['mobile']}
                </p>
                <p class="cginfo">
                    <span>当前仓库</span>{$info['cidName']}
                </p>
                <p class="cginfo">
                    <span style="float: left;">单据备注</span>
                    <span style="width: 77%;display: inline-block;color: #333;">{$info['mark']}</span>
                </p>

            </li>
        </ul>

        <ul class="productinfo" id="pro3">
            <p style="color: #666;">产品</p>
            {volist name="list" id="vo"}
            <li dataid="{$vo['shopid']}">
                <div class="infoleft"><img src="/plan/caigou/img/product.png"/></div>
                <div class="inforight">
                    <p>{$vo.cname}</p>
                    <p class="infop2">仓库：{$info['cidName']}</p>
                    <p class="infop2">类型：{$vo['types']}</p>

                    <p class="infop3"><span id="znum{$vo['shopid']}">下单数量 × {$vo.num}</span>本</p>
                       <p class="infop3">×<span id="znums{$vo['shopid']}">变更数量
                           {if condition="($info['status'] eq 5 or $info['status'] eq -21) and $info['publisher'] eq $userid"}
                           <style>
                               .changeNum{
                                   background: #fff;
                                   outline: none;
                                   border: 1px solid #666;
                                   font-size: 0.3rem;
                                   margin-top: 0.1rem;
                                   width: 1rem;
                                   text-align: center;
                               }
                           </style>
                                <input type="number" class="changeNum" dataid="{$vo.shopid}" value="{$vo.nums}">
                           {else}
                          x {$vo.nums}
                           {/if}
                       </span>本</p>

                </div>
            </li>
            {/volist}

        </ul>
        {notempty name="worklist"}

        <ul class="list_info">
            <p class="title">审批流程</p>
            {volist name="worklist" id="vo"}

            <li>
                {if condition="$vo['status'] eq 2"}
                <img class="tx" src="/plan/caigou/img/bohui.jpg"/>
                {else}
                <img class="tx" src="/plan/caigou/img/ing.jpg"/>
                {/if}
                <p class="question">

                    <img src="{$vo['user']['avatar']}"/>

                    <span>{$vo['user']['username']} ·             {if condition="$vo['status'] eq 1"}
已通过 {elseif condition="$vo['status'] eq 2"}已驳回{else}审批中{/if}</span>
                </p>

                <p class="infodate">
                    {$vo.mark}
                </p>

            </li>

            {/volist}
        </ul>
        {/notempty}
        <div class="sug"  {in name="info['status']" value="9"}style="margin-top:0.2rem"{else}style="margin-top:0"{/in}>
        {in name="info['status']" value="9"}
        {if condition="$userid eq $leader"}


        <p class="titie">审批意见</p>
        <textarea style="height: 2rem;" id="mark"></textarea>
        {/if}

        {/in}
    </div>


    {if condition="$info['status'] eq 10 "}
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="提交审核"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq 9"}
    {if condition="$userid eq $leader"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq 8"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 7"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 5"}
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>申请变更</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="完成入库"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq -4"}
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="作废"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq -1"}<!--作废订单1-->
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>返回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="添加"/></div>
    </div>
    {/if}

    {elseif  condition="$info['status'] eq -2"}<!--作废订单1-->
    {if condition="$changePerson eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>拒绝变更</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="确认变更"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq -20"}<!--作废订单1-->
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>返回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="完成入库"/></div>
    </div>
    {/if}
    {elseif  condition="$info['status'] eq -21"}<!--作废订单1-->
    {if condition="$info['publisher'] eq $userid"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>申请变更</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="作废"/></div>
    </div>
    {/if}

    {elseif  condition="$info['status'] eq 1"}
        {if condition="$info['publisher'] eq $userid"}

        <div class="cgbutton">
            <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>已完成</div></a>
        <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="要货"/></div>
        </div>
        {/if}
    {/if}


</section>
</body>
<script>
    var tempId;

    $(function () {

        $("#zbianji").click(function () {
            let data = JSON.parse($(this).attr("data-info"));
            switch (data.status){
                case 10:
                    location.href="/index/fgs/edit/id/"+data.id;
                    break;
                case 9:
                    examine(9);
                    break;
                case 8:
                    examine(8);
                    break;
                case 7:
                    examine(7);
                    break;
                case 5:
                    examines(5);
                    break;
                case -2:
                    examines(-2);
                    break;
                case -21:
                    examines(-21);
                    break;
                case -4:
                    location.href="/index/fgs/edit/id/"+data.id;
                    break;
                case -1://申请变更
                    location.href="/index/fgs/index/";
                    break;
                case 1:
                    location.href="/index/fgs/index/";
                    break;

            }
        });
        $("#tijiao").click(function () {

            let data = JSON.parse($(this).attr("data-info"));
            switch (data.status){
                case 10:
                    //提交审核
                    oper(10);
                    break;
                case 9:

                    oper(9);
                    break;
                case 8:
                    oper(8);
                    break;
                case 7:
                    oper(7);
                    break;
                case 5:
                    oper(1);
                case 2:
                    oper(2);
                case 5:
                    oper(5);
                    break;
                case -2:
                    oper(-2);
                    break;
                case -20:
                    oper(-20);
                    break;
                case -4:
                    oper(-4);
                    break;
                case -1:
                    location.href="/index/fgs/inStore/";
                    break;
                case 1:
                    location.href="/index/fgs/inStore/";
                    break;
            }
        });
    })
    function oper(status) {

        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        $(".cgclose,.cgcontinue").addClass("disabled");
        let mark = $("#mark").val();
        layer.open({type: 2,  shadeClose: false});
        $.ajax({
            type:"post",
            url:"/index/fgs/oper",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {

                layer.closeAll();
                if (data.code==1){
                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },800);
                } else{
                   /* layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/outpur/rkindex"
                    },800);*/
                }
            }
        })
    }
    function examines(status) {
        let obj=[];
        $(".changeNum").each(function (e,i) {
            //obj.(this)
            obj.push({name:$(this).attr('dataid'),value:$(this).val()});
        });
        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        $(".cgclose,.cgcontinue").addClass("disabled");
        layer.open({type: 2,  shadeClose: false});

        $.ajax({
            type:"post",
            url:"/index/fgs/change",
            data:{id:{$info['id']},status:status,data:obj},
            success:function (data) {
                layer.closeAll();

                if (data.code==1){
                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },600);
                } else{

                  /*  layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/fgs/index"
                    },200);*/
                }

            }

        })
    }
    function examine(status) {

        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;

        let mark = $("#mark").val();

        if (mark==''){
            layer.open({
                content:'请输入驳回意见' ,
                skin: 'msg',
                time: 2 //2秒后自动关闭
            });
            return false;
        }
        $(".cgclose,.cgcontinue").addClass("disabled");
        layer.open({type: 2,  shadeClose: false});

        $.ajax({
            type:"post",
            url:"/index/fgs/reject",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {
                layer.closeAll();

                if (data.code==1){
                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },600);
                } else{

                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/Outpur/rkindex"
                    },200);
                }

            }

        })
    }
</script>
</html>
